package com.icinfo.cloud.provider.punish.warning.controller;

import com.alibaba.fastjson.JSONObject;
import com.icinfo.cloud.provider.punish.warning.dto.AllClueDto;
import com.icinfo.cloud.provider.punish.warning.dto.CurrentClueDto;
import com.icinfo.cloud.provider.punish.warning.dto.WarnTokenDto;
import com.icinfo.cloud.provider.punish.warning.service.IEarlyWarningService;
import com.icinfo.cloud.provider.punish.warning.vo.WarnTokenVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.tools.utils.StringUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/irs/earlyWarning")
public class EarlyWarningController {

    @Resource
    private IEarlyWarningService earlyWarningService;

    /**
     * 预警token获取
     * @param warnTokenDto
     * @return
     */
    @RequestMapping("/getWarnToken")
    public Result<WarnTokenVo> getWarnToken(@RequestBody @Validated WarnTokenDto warnTokenDto){
        WarnTokenVo warnToken = earlyWarningService.getWarnToken(warnTokenDto);
        if(!ObjectUtils.isEmpty(warnToken)){
            return Result.success("请求成功",warnToken);
        }
        return Result.error("获取失败");
    }
    /**
     * 预警线索查询
     * @author liyafeng
     * @date 2022/7/6
      * @param allClueDto
     * @return {@link Result}
     */
    @RequestMapping("/getAllClue")
    public Result<JSONObject> getAllClue(@RequestBody @Validated AllClueDto allClueDto){
        JSONObject object=earlyWarningService.getAllClue(allClueDto);
        return Result.success("获取成功！",object);
    }
    /**
     * 获取当前待办预警线索
     * @author liyafeng
     * @date 2022/7/6
      * @param currentClueDto
     * @return {@link Result< JSONObject>}
     */
    @RequestMapping("/getCurrentClue")
    public Result<JSONObject> getCurrentClue(@RequestBody @Validated CurrentClueDto currentClueDto){
        JSONObject object=earlyWarningService.getCurrentClue(currentClueDto);
        return Result.success("获取成功！",object);
    }
   /**
    *预警线索待办列表页面
    * @author liyafeng
    * @date 2022/7/6
     * @param warnToken
    * @return {@link Result< String>}
    */
    @RequestMapping("/getWarningClueCurrentPage")
    public Result<String> getWarningClueCurrentPage(@RequestParam("warnToken") String warnToken){
        String  warningClueCurrentPage=earlyWarningService.getWarningClueCurrentPage(warnToken);
        return Result.success("获取成功！",warningClueCurrentPage);
    }
    /**
     * 预警线索反馈页面
     * @author liyafeng
     * @date 2022/7/6
      * @param warnToken
     * @return {@link Result< String>}
     */
    @RequestMapping("/getWarningClueHandlePage")
    public Result<String> getWarningClueHandlePage(@RequestParam("warnToken") String warnToken){
        String  warningClueHandlePage=earlyWarningService.getWarningClueHandlePage(warnToken);
        return Result.success("获取成功！",warningClueHandlePage);
    }
}
